Completed
Push — master ( 27b20f...cb95fb )
by greg
49s
created

editor.js ➔ describe(ꞌEditorꞌ)   A

Complexity

Conditions 1
Paths 2

Size

Total Lines 47

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 47
rs 9.0303

2 Functions

Rating   Name   Duplication   Size   Complexity  
B editor.js ➔ ... ➔ it(ꞌcmsEditor.printInput()ꞌ) 0 28 1
A editor.js ➔ ... ➔ it(ꞌcmsEditor.folders()ꞌ) 0 6 1
1
import chai from 'chai'
2
import path from 'path'
3
import sinonChai from'sinon-chai'
4
chai.use(sinonChai)
5
import sinon from 'sinon'
6
import {config} from '../src/cli'
7
config.set({root: path.join(__dirname,'fixtures')})
8
9
import {
10
  cmsEditor,
11
  abeExtend
12
} from '../src/cli'
13
14
import data from './fixtures/editor/index'
15
16
describe('Editor', function() {
17
  
18
  /**
19
   * cmsEditor.printInput
20
   * 
21
   */
22
  it('cmsEditor.printInput()', function() {
23
    var val = data.text;
24
    this.sinon = sinon.sandbox.create();
25
    this.sinon.stub(abeExtend.hooks.instance, 'trigger', function(param, html){
26
      return (param === 'beforeEditorInput') ? val : html;
27
    })
28
29
    var result = cmsEditor.printInput(val, {})
30
    chai.expect(result).to.be.a('string')
31
    var value = result.match(/value="[a-zA-Z0-9-]*"/ig)[0]
32
    chai.expect(value).to.equal('value="val2"')
33
    var reload = result.match(/reload="[a-zA-Z0-9-]*"/ig)[0]
34
    chai.expect(reload).to.equal('reload="val3"')
35
    var tabIndex = result.match(/tabIndex="[a-zA-Z0-9-]*"/ig)[0]
36
    chai.expect(tabIndex).to.equal('tabIndex="val4"')
37
    var dataRequired = result.match(/data-required="[a-zA-Z0-9-]*"/ig)[0]
38
    chai.expect(dataRequired).to.equal('data-required="val5"')
39
    var dataDisplay = result.match(/data-display="[a-zA-Z0-9-]*"/ig)[0]
40
    chai.expect(dataDisplay).to.equal('data-display="val6"')
41
    var dataVisible = result.match(/data-visible="[a-zA-Z0-9-]*"/ig)[0]
42
    chai.expect(dataVisible).to.equal('data-visible="val7"')
43
    var dataAutocomplete = result.match(/data-autocomplete="[a-zA-Z0-9-]*"/ig)[0]
44
    chai.expect(dataAutocomplete).to.equal('data-autocomplete="val8"')
45
    var placeholder = result.match(/placeholder="[a-zA-Z0-9-]*"/ig)[0]
46
    chai.expect(placeholder).to.equal('placeholder="val9"')
47
48
    this.sinon.restore()
49
  });
50
51
  /**
52
   * cmsEditor.folders
53
   * 
54
   */
55
  it('cmsEditor.folders()', function() {
56
    var result = cmsEditor.folders([{path: ''}], 1, null, {'level-1': 'my wording'})
57
    var wordingExist = result.indexOf('my wording')
58
    chai.expect(result).to.be.a('string')
59
    chai.expect(wordingExist).to.equal(110)
60
  });
61
62
});
63